package org.ikastola

import ikastola.Constants;

import java.util.Date;

class Guardian {

	String name
	String lastname
	String housephone
	String mobile
	String email
	String officephone
	String prefer
	Integer deleted
	Date classCreated
	Date classUpdated

    static constraints = {
		name blank: false
		lastname blank: false
		deleted blank: false
		classCreated nullable: true
		classUpdated nullable: true
		prefer: nullable:true
    }
	
	def static list() {
		return findAllByDeleted(Constants.NOT_DELETED)
	}
	
	def getPreferedPhone() {
		switch(prefer) {
			case "mobile": return mobile; break;
			case "office": return officephone; break;
			default: return housephone;
		}
	}
	
}
